package com.example.springbootaccesslimit.config;

/**
 * 拦截器配置
 * @author lxiaol
 * @date 2022年02月09日 22:40
 */
import com.example.springbootaccesslimit.interceptor.AccessLimitInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {

    @Bean
    public AccessLimitInterceptor getAccessLimitInterceptor(){
        return new AccessLimitInterceptor();
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(getAccessLimitInterceptor()).addPathPatterns("/**");
        registry.addInterceptor(getAccessLimitInterceptor());
        super.addInterceptors(registry);
    }

}